package com.ruoyi.system.service.impl.basic;

import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.basic.BasicCompaniesMapper;
import com.ruoyi.system.domain.db.basic.BasicCompanies;
import com.ruoyi.system.service.IBasicCompaniesService;

/**
 * 公司管理模块Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-07-25
 */
@Service
@Slf4j
public class BasicCompaniesServiceImpl implements IBasicCompaniesService 
{
    @Autowired
    private BasicCompaniesMapper basicCompaniesMapper;

    /**
     * 查询公司管理模块
     * 
     * @param companyId 公司管理模块主键
     * @return 公司管理模块
     */
    @Override
    public BasicCompanies selectBasicCompaniesByCompanyId(Long companyId)
    {
        return basicCompaniesMapper.selectBasicCompaniesByCompanyId(companyId);
    }

    /**
     * 查询公司管理模块列表
     * 
     * @param basicCompanies 公司管理模块
     * @return 公司管理模块
     */
    @Override
    public List<BasicCompanies> selectBasicCompaniesList(BasicCompanies basicCompanies)
    {
        return basicCompaniesMapper.selectBasicCompaniesList(basicCompanies);
    }

    /**
     * 新增公司管理模块
     * 
     * @param basicCompanies 公司管理模块
     * @return 结果
     */
    @Override
    public int insertBasicCompanies(BasicCompanies basicCompanies)
    {

        LoginUser loginUser = SecurityUtils.getLoginUser();
        basicCompanies.setCompanyId(null);
        basicCompanies.setCreateBy(loginUser.getUserId());
        basicCompanies.setUpdateBy(loginUser.getUserId());
        basicCompanies.setCreateTime(DateUtils.getNowDate());
        basicCompanies.setUpdateTime(DateUtils.getNowDate());
        return basicCompaniesMapper.insertBasicCompanies(basicCompanies);
    }

    /**
     * 修改公司管理模块
     * 
     * @param basicCompanies 公司管理模块
     * @return 结果
     */
    @Override
    public int updateBasicCompanies(BasicCompanies basicCompanies)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        basicCompanies.setUpdateTime(DateUtils.getNowDate());
        basicCompanies.setUpdateBy(loginUser.getUserId());
        return basicCompaniesMapper.updateBasicCompanies(basicCompanies);
    }

    /**
     * 批量删除公司管理模块
     * 
     * @param companyIds 需要删除的公司管理模块主键
     * @return 结果
     */
    @Override
    public int deleteBasicCompaniesByCompanyIds(Long[] companyIds)
    {
        return basicCompaniesMapper.deleteBasicCompaniesByCompanyIds(companyIds);
    }

    /**
     * 删除公司管理模块信息
     * 
     * @param companyId 公司管理模块主键
     * @return 结果
     */
    @Override
    public int deleteBasicCompaniesByCompanyId(Long companyId)
    {
        return basicCompaniesMapper.deleteBasicCompaniesByCompanyId(companyId);
    }
}
